package org.teamh.artificialIntelligence;

import org.teamh.connection.json.command.JsonSender;
import org.teamh.logic.datamodel.CreepDescription;

public class Attacker {
	
	private Attacker() {}
	
	public static void attack() {
//		//System.out.println("attack enemy");
		
		//TODO decide, whether to send all creeps at one time or send several creeps. 
		//TODO decide whether to send the most expensive creep, or several cheaper creeps
		
		CreepDescription best = null;
		for(CreepDescription c: AIInterfaceManager.datamodelManager.getCreepDescriptions().values()) {
			if(c.getPrice() <= AIInterfaceManager.user.getUserAssets().getBalanceForSimulation()) {
				if(best == null) {
					best = c;
				} else {
					if(c.getHealthMax() > best.getHealthMax()) {
						best = c;
					}
				}
			}
		}
		
		if(best != null) {
			//System.out.println("requested creep");
			AIInterfaceManager.user.getUserAssets().removeFromBalanceForSimulation(best.getPrice());
			JsonSender.createCreep(best.getType());
		}
	}
}
